import 'package:k3cloud_api/params/request_param.dart';

/// it is used to build parameters to request the draft interface.
class DraftParam extends RequestParam {
  @override
  String getRequestPath() {
    return "DynamicFormService.Draft";
  }

  @override
  Map<String, dynamic> toJson() {
    Map<String, dynamic> data = {};
    if (needUpDateFields != null) data["needUpDateFields"] = needUpDateFields;
    if (needReturnFields != null) data["needReturnFields"] = needReturnFields;
    if (isDeleteEntry != null) data["isDeleteEntry"] = isDeleteEntry;
    if (subSystemId != null) data["subSystemId"] = subSystemId;
    if (isVerifyBaseDataField != null) data["isVerifyBaseDataField"] = isVerifyBaseDataField;
    if (isEntryBatchFill != null) data["isEntryBatchFill"] = isEntryBatchFill;
    if (validateFlag != null) data["validateFlag"] = validateFlag;
    if (numberSearch != null) data["numberSearch"] = numberSearch;
    if (interationFlags != null) data["interationFlags"] = interationFlags;
    if (model != null) data["model"] = model;

    Map<String, dynamic> json = {};
    if (formId != null) json["formId"] = formId;
    json["data"] = data;
    return json;
  }

  String? formId;
  List<String>? needUpDateFields;
  List<String>? needReturnFields;
  bool? isDeleteEntry;
  String? subSystemId;
  bool? isVerifyBaseDataField;
  bool? isEntryBatchFill;
  bool? validateFlag;
  bool? numberSearch;
  String? interationFlags;
  Map<String, dynamic>? model;

  static _Builder builder() {
    return _Builder();
  }
}

class _Builder {
  final DraftParam _param = DraftParam();

  DraftParam build() => _param;
  
  _Builder formId(String formId) {
    _param.formId = formId;
    return this;
  }

  _Builder needUpDateFields(List<String> needUpDateFields) {
    _param.needUpDateFields = needUpDateFields;
    return this;
  }

  _Builder needReturnFields(List<String> needReturnFields) {
    _param.needReturnFields = needReturnFields;
    return this;
  }

  _Builder isDeleteEntry(bool isDeleteEntry) {
    _param.isDeleteEntry = isDeleteEntry;
    return this;
  }

  _Builder subSystemId(String subSystemId) {
    _param.subSystemId = subSystemId;
    return this;
  }

  _Builder isVerifyBaseDataField(bool isVerifyBaseDataField) {
    _param.isVerifyBaseDataField = isVerifyBaseDataField;
    return this;
  }

  _Builder isEntryBatchFill(bool isEntryBatchFill) {
    _param.isEntryBatchFill = isEntryBatchFill;
    return this;
  }

  _Builder validateFlag(bool validateFlag) {
    _param.validateFlag = validateFlag;
    return this;
  }

  _Builder numberSearch(bool numberSearch) {
    _param.numberSearch = numberSearch;
    return this;
  }

  _Builder interationFlags(List<String> interationFlags) {
    _param.interationFlags = interationFlags.join(";");
    return this;
  }

  _Builder model(Map<String, dynamic> model) {
    _param.model = model;
    return this;
  }
}